<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" th:href="@{/res/css/amazeui.min.css}"/>
    <link rel="stylesheet" th:href="@{/res/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{/res/css/admin.css}"/>
    <script type="text/javascript" th:src="@{/js/jquery-1.11.3.min.js}"></script>

    <style>
        .adminInfo{
            position: relative;
            top:10%;
            left:38%;
            font-size: 18px;
        }
        .row{
            padding-bottom: 20px;
        }
        label{
            font-weight: normal;
        }
        span{
            color: #0b6cbc;
        }
        #btn-pw{
            position: relative;
            top:0px;
            left:0px;
        }
        #btn-list{
            position: relative;
            top:0px;
            left:10px;
        }
    </style>
</head>

<body>
<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">我的钱包</strong>
            <small></small>
        </div>
    </div>

    <hr>

    <div class="am-g">
        <form class="adminInfo" style="padding-top: 20px;">

            <div class="row">
                <label>用户名称：</label><a href="Javascript:return false;"><span id="name"></span></a>
            </div>

            <div class="row">
                <label>账户余额：</label><a href="Javascript:return false;"><span id="balance"></span></a>
            </div>
            <div class="row">

                <div>
                    <a class="am-btn am-btn-primary" onclick="updatePwd()" id="btn-pw">修改支付密码</a>
                    <a class="am-btn am-btn-primary" onclick="checklist()" id="btn-list">查看流水</a>
                </div>
            </div>
        </form>
    </div>
</div>
</body>

<script>
    //从url得到uid
    var result=new Object();
    result=getParameter();
    var uid=result["uid"];
    console.log(uid);

    //初始化用户名和余额
    $(function () {
        $.ajax({
            type: 'post',
            url: '/wallet/selectBalanceByUid',
            data: {uid: uid},
            dataType: 'json',
            success: function (mydata) {
                $("#name").html(mydata[0]);//用户名
                $("#balance").html(mydata[1]);//余额
            },
            error: function () {
                alert("请求钱包信息失败！");
            }
        })
    })

    //修改密码
    function updatePwd() {
        window.location.href = "/walletUpdatePw?uid="+uid;
    }

    //查看账户记录
    function checklist() {
        window.location.href = "/mvowalletlist?uid="+uid;
    }

    //解析url传值
    function getParameter() {
        var url=location.search;//获取url?后面的内容
        var result=new Object();
        if(url.indexOf("?")!= -1){
            var str=url.substr(1);
            strs=str.split("&");
            for(var i=0;i<strs.length;i++){
                result[strs[i].split("=")[0]]=decodeURIComponent(strs[i].split("=")[1]);
            }
        }
        return result;
    }
</script>
</html>